package vno.fux.ui
{
	import flash.events.MouseEvent;

	public class PicButtonController extends BaseComponentController
	{
		public function PicButtonController(model_:BaseComponentModel)
		{
			super(model_);
		}
		public function play():void
		{
			var model:PicButtonModel = (_model as PicButtonModel);
			if(model.soundChannel)
				return;
			model.soundChannel = model.soundSource.play(0, int.MAX_VALUE);
			model.update();
		}
		public function stop():void
		{
			var model:PicButtonModel = (_model as PicButtonModel);
			if(!model.soundChannel)
				return;
			model.soundChannel.stop();
			model.soundChannel = null;
			model.update();
		}
		public function handleClick(event:MouseEvent):void
		{
			var model:PicButtonModel = (_model as PicButtonModel);
			if(model.soundChannel)
			{
				model.soundChannel.stop();
				model.soundChannel = null;
			}
			else
			{
				model.soundChannel = model.soundSource.play(0, int.MAX_VALUE);
			}
			model.update();
		}
	}
}
